// Desc: 公共方法
import * as XLSX from "xlsx";

export const defaultMockMenu = [
    {
        code: 'storage-monitoring',
        name: '储能监测',
        icon: 'img_0',
        activeIcon: 'img_0_active',
    },
    {
        name: '光伏预测',
        code: 'photovoltaic-forecast',
        icon: 'img_2',
        activeIcon: 'img_2_active',
        children: [
            {
                name: '实时预测',
                code: 'photovoltaic-real-time-forecast',
            },
            {
                name: '日前预测',
                code: 'photovoltaic-day-forecast',
            },
        ]
    },
    {
        name: '光储协调',
        code: 'photovoltaic-storage-coordination',
        icon: 'img_3',
        activeIcon: 'img_3_active',
    },
    {
        name: '报警管理',
        code: 'alarm',
        icon: 'img_4',
        activeIcon: 'img_4_active',
        children: [
            {
                name: '实时报警',
                code: 'alarm-data',
            },
            {
                name: '历史报警',
                code: 'alarm-history',

            }
        ]
    },
    {
        name: '数据查询',
        code: 'data-query',
        icon: 'img_5',
        activeIcon: 'img_5_active',
        children: [
            {
                name: '温度数据',
                code: 'temperature-data',
            },
            {
                name: '气压数据',
                code: 'pressure-data',
            },
            {
                name: '湿度数据',
                code: 'humidity-data',
            },
            {
                name: '辐照度数据',
                code: 'radiation-data',
            },
            {
                name: '总光伏功率数据',
                code: 'total-photovoltaic-power-data',
            },
            {
                name: '储能无功数据',
                code: 'storage-reactive-power-data',
            },
            {
                name: '储能有功数据',
                code: 'storage-active-power-data',
            },
            {
                name: '可充电量数据',
                code: 'rechargeable-amount-data',
            },
            {
                name: '可放电量数据',
                code: 'dischargeable-amount-data',
            },
            {
                name: '电池荷电量数据',
                code: 'battery-charge-amount-data',
            }
        ]
    },
    {
        name: '系统图',
        code: 'system-diagram',
        icon: 'img_3',
        activeIcon: 'img_3_active',
    },
    {
        code: 'data-entry',
        name: '数据录入',
        icon: 'img_1',
        activeIcon: 'img_1_active',
        children: [
            {
                code: 'station-data',
                name: '场站数据',
            },
            {
                code: 'storage-monitoring-data',
                name: '储能数据',
            },
            {
                name: '光伏预测数据',
                code: 'photovoltaic-forecast-data',
            },
            {
                name: '光储协调数据',
                code: 'photovoltaic-storage-coordination-data',
            },
            {
                name: '数据查询数据',
                code: 'data-query-data',
            },
            {
                name: '系统图数据',
                code: 'system-data',
            }
        ]
    },
    {
        name: '报表管理',
        code: 'report-management',
        children: [
            /**
             *  {
             *             // 报表电量
             *             name: 'report-electricity',
             *             path: '/report/electricity',
             *             component:  () => import('@/views/report/electricity.vue'),
             *         },
             *         {
             *             // 报表-光伏预测
             *             name: 'report-pv-forecast',
             *             path: '/report/pv-forecast',
             *             component:  () => import('@/views/report/pv-forecast.vue'),
             *         },
             *         {
             *             // 报表-光储协调
             *             name: 'report-pv-storage-coordination',
             *             path: '/report/pv-storage-coordination',
             *             component:  () => import('@/views/report/pv-storage-coordination.vue'),
             *         },
             *         {
             *             // 报表-数据查询
             *             name: 'report-data-query',
             *             path: '/report/data-query',
             *             component:  () => import('@/views/report/data-query.vue'),
             *         }
             */
            {
                name: '报表-电量信息',
                code: 'report-electricity',
            },
            {
                name: '报表-光伏实时预测',
                code: 'report-pv-forecast',
            },
            {
                name: '报表-光伏日前预测',
                code: 'report-pv-forecast-day',
            },
            {
                name: '报表-光储实时协调',
                code: 'report-pv-storage-coordination',
            },
            {
                name: '报表-光储日前协调',
                code: 'report-pv-storage-coordination-day',
            },
            {
                name: '报表-数据查询',
                code: 'report-data-query',
            }
        ]
    },
    {
        name: '用户管理',
        code: 'user-management',
        icon: 'img_3',
        activeIcon: 'img_3_active',
        children: [
            {
                name: '角色管理',
                code: 'role',
            },
            {
                name: '用户管理',
                code: 'user',
            }
        ]
    },
]

export const exportToExcel = (name,data = []) => {
    if (!name) {
        name = '导出文件'
    }
    if (!data) return
    // 创建一个工作簿
    const workbook = XLSX.utils.book_new();
    // 创建一个工作表
    const worksheet = XLSX.utils.aoa_to_sheet([
        ...data
    ]);

    // 将工作表添加到工作簿
    XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');

    // 生成Excel文件
    XLSX.writeFile(workbook, name + '.xlsx');
};